package com.siwei.mes.controller.system;

import com.siwei.mes.entity.system.Signature;
import com.siwei.mes.service.system.SignatureService;
import org.springframework.web.bind.annotation.*;
import com.siwei.mes.common.query.PageQuery;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.common.validator.AddGroup;
import com.siwei.mes.common.validator.PageGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.validation.annotation.Validated;

import static com.siwei.mes.common.exception.handler.MessageHandler.assertTrue;

import javax.annotation.Resource;

/**
 * 打印电子签名表相关
 *
 * @author makejava
 * @since 2025-08-31 00:02:02
 */
@Api(value = "打印电子签名表")
@RestController
@RequestMapping("signature")
public class SignatureController {
    @Resource
    private SignatureService signatureService;

    @ApiOperation(value = "新增打印电子签名表")
    @PostMapping("/create")
    public Json create(@RequestBody @Validated(AddGroup.class) Signature entity) {
        return Json.succ().data(ApiResult.addColumn("id", signatureService.create(entity)));
    }

    @ApiOperation(value = "修改打印电子签名表")
    @PostMapping("/update")
    public Json update(@RequestBody @Validated(UpdateGroup.class) Signature entity) {
        signatureService.update(entity);
        return Json.succ().data(new ApiResult());
    }
    @ApiOperation(value = "删除打印电子签名表")
    @PostMapping("/delete")
    public Json delete(@RequestBody Signature entity) {
        signatureService.delete(entity.getId());
        return Json.succ().data(new ApiResult());
    }
    @ApiOperation(value = "分页获取打印电子签名表")
    @PostMapping("/page")
    public Json appPage(@RequestBody @Validated(PageGroup.class) PageQuery<Signature, Signature> query) {
        return Json.succ().data(signatureService.getPage(query));
    }
    @ApiOperation(value = "根据主键id获取打印电子签名表")
    @GetMapping("loadById")
    public Json loadById(@RequestParam("id") Long id) {
        return Json.succ().data(signatureService.loadById(id));
    }
    @ApiOperation(value = "获取所有打印电子签名表")
    @PostMapping("getAll")
    public Json getAll(@RequestBody Signature entity) {
        return Json.succ().data(ApiResult.addList(signatureService.getAll(entity)));
    }

}
